package com.lqian.functional_intreface;

import com.lqian.method_ref.Supplier;

import java.util.Arrays;
import java.util.Random;

/**
 * 产生指定长度的随机数数组
 */
public class SupplierFunctionInterface {
    public static void main(String[] args) {
        Supplier<Integer> supplier = new Supplier<Integer>() {
            @Override
            public Integer get() {
                return new Random().nextInt(100); //产生随机数
            }
        };

        int[] arrs = getArrs(supplier,10);
        System.out.println(Arrays.toString(arrs));
    }



    public static int[] getArrs(Supplier<Integer> supplier,int count){
        int[] arrs = new int[count];
        for (int i = 0; i <arrs.length ; i++) {
            arrs[i] = supplier.get();
        }
        return arrs;
    }
}
